package com.zhida.smartcontrol.dialog.grouplistdialog;

import com.alibaba.fastjson.JSON;
import com.yanzhenjie.kalle.Params;
import com.zhida.smartcontrol.common.Api;
import com.zhida.smartcontrol.knet.KalleCallBack;
import com.zhida.smartcontrol.mvp.BasePresenterImpl;
import com.zhida.smartcontrol.pagectrl.projectdetail.GroupBean;

import java.util.List;

public class GroupListDialogPresenter extends BasePresenterImpl<GroupListDialogContract.View> implements GroupListDialogContract.Presenter {
    @Override
    public void requestGroupList(String projectId) {
        Params params = Params.newBuilder()
                .add("projectBaseId", projectId)
                .build();
        mKalleCenter.get(Api.GROUP_LIST, params, true, new KalleCallBack() {
            @Override
            public void onSuccess(String result, String msg) {
                List<GroupBean> groupList = JSON.parseArray(result, GroupBean.class);
                mView.showGroup(groupList);
            }

            @Override
            public void onFailed(String msg) {
                mView.showMsg(msg);
            }
        });
    }
}
